package actions;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;

//@Validation

@SuppressWarnings("serial")
public class AnnotationAction extends ActionSupport {

	private String username = null;

	private String password = null;

	@RequiredStringValidator(message = "Favor, Informar o login.")
	public String getUsername() {
		return username;
	}

	public void setUsername(String value) {
		username = value;
	}

	@RequiredStringValidator(message = "Favor, Informar a senha.")
	public String getPassword() {
		return password;
	}

	public void setPassword(String value) {
		password = value;
	}

	public String execute() throws Exception {

		System.out.println("Validating login");
		if (!getUsername().equals("Admin") || !getPassword().equals("Admin")) {
			addActionError("Usuario/senha invalido. Informe corretamente.!");
			return ERROR;
		} else {
			return SUCCESS;
		}
	}
}